<template>
	<view class="">
		<view class="search-wrap">
			<view class="input-item flex-row align-center">
				<input v-model="searchValue" class="input" placeholder="请输入批次号/物料编码" />
				<image v-if="searchValue" class="s-input-icon clear-icon" src="/static/images/clear.png" @click="clearSearch"></image>
				<icon type="search" size="22" @click="stock" color="#4599AD" class="icon" />
			</view>
		</view>
		<view class="search-value-wrap">
			<view class="text-title">查询结果（{{tableData.length}}条）</view>
			<view class="item-wrap" v-for="(item,index) in tableData" :key="index">
				<view class="item-header  flex-row-start" :class="item.status =='NORMAL'?'status1':'status2'">
					<image class="bar-icon" src="/static/images/bar_icon.png" mode="widthFix"></image>
					<view>
						<view style="font-size: 24rpx;">批次号</view>
						<view class="code-text">{{item.batchNo}}</view>
					</view>
					<image v-if="item.status =='NORMAL'" class="status_icon" src="/static/images/status_icon1.png" mode="widthFix"></image>
					<image v-else class="status_icon" src="/static/images/status_icon2.png" mode="widthFix"></image>
					<image class="search-bg" src="/static/images/search_bg.png" mode="widthFix"></image>
				</view>
				<view style="padding: 10rpx 24rpx;">
					<view class="flex-row">
						<view class="sub-item">
							<view class="text1">物料编码</view>
							<view class="text2">{{item.productNo}}</view>
						</view>
						<view class="line"></view>
						<view class="sub-item">
							<view class="text1">物料名称</view>
							<view class="text2">{{item.productName}}</view>
						</view>
					</view>
					<view class="item-content flex-row-between">
						<view class="sub-item">
							<view class="text1">库存编号</view>
							<view class="text2">{{item.storehouseLocationNo}}</view>
						</view>
						<view class="line"></view>
						<view class="sub-item">
							<view class="text1">库存数量/单位</view>
							<view class="text2">{{item.qty}}</view>
						</view>
					</view>
					<view class="item-content flex-row-between">
						<view class="sub-item">
							<view class="text1">订单编号</view>
							<view class="text2">{{item.orderNo}}</view>
						</view>
						<view class="line"></view>
						<view class="sub-item">
							<!-- <view class="text1">库存数量/单位</view>
							<view class="text2">{{item.qty}}</view> -->
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>

import { stock } from "./api"

	export default {
		data() {
			return {
				searchValue: '',
				tableData: []
			}
		},
		onLoad: function() {
			// this.stock();
		},
		onNavigationBarButtonTap(obj){
			if(obj.text == '重置'){
				this.searchValue = '';
				this.tableData = [];
			}
		},
		methods: {
			toPage(page) {
				this.$tab.navigateTo(page);
			},
			stock(){
				stock({ unionData: this.searchValue, pageNum:0, pageSize:1000 }).then(res=>{
					this.tableData = res.rows
				})
			},
			clearSearch() {
				this.searchValue = '';
				this.tableData = [];
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #FCFCFC;
	}
	.search-wrap {
		position: absolute;
		z-index: 2;
		width: 100vw;
		height: 152rpx;
		background-color: #4599AD;
		padding: 24rpx 48rpx;

		.input-item {
			padding: auto 24rpx;
			background-color: #F2F6F8;
			height: 88rpx;
			border-radius: 8rpx;

			.icon {
				font-size: 46rpx;
				margin-left: 20rpx;
				margin-right: 24rpx;
				color: #8997A8;
			}

			.input {
				width: 100%;
				font-size: 28rpx;
				line-height: 40rpx;
				text-align: left;
				padding-left: 24rpx;
			}

		}
	}
	.search-value-wrap{
		padding: 152rpx 24rpx 0;
		.text-title{
			padding: 8rpx 0;
			font-size: 24rpx;
			color:#8997A8
		}
		.item-wrap{
			width: 100%;
			// height: 357rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 3rpx 12rpx rgba(85,107,133,0.16);
			border-radius: 8rpx;
			overflow: hidden;
			margin-bottom: 16rpx;
			.status1{
				background: linear-gradient(133deg, #4599AD 0%, #3ECBBD 100%);
			}
			.status2{
				background: linear-gradient(133deg, #F89861 0%, #F96C56 100%);
			}
			.item-header{
				padding: auto 36rpx auto 24rpx;
				position: relative;
				width: 100%;
				height: 118rpx;
				color: #fff;
				.search-bg{
					width: 100%;
					position: absolute;
					bottom: 0;
				}
				.bar-icon{
					width: 68rpx;
					height: 54rpx;
					margin-left: 24rpx;
					margin-right: 12rpx;
				}
				.status_icon{
					width: 56rpx;
					height: 56rpx;
					position: absolute;
					right: 36rpx;
					top: 30rpx;
				}
				.code-text{
					font-size: 28rpx;
					font-weight: bold;
				}
			}
			
			.item-content{
				border-top: 1px solid rgba(85, 107, 133, 0.16);
			}
			.line{
				width: 1rpx;
				height: 80rpx;
				background-color: rgba(85, 107, 133, 0.16);
				margin: 16rpx 24rpx;
			}
			.text1{
				font-size: 24rpx;
				color: #8997A8;
				padding-bottom: 8rpx;
			}
			.text2{
				font-size: 30rpx;
				color: #0D1116;
			}
			
			.sub-item{
				flex: 1;
				padding: 0;
			}
		}
	}
</style>
